home *** CD-ROM | disk | FTP | other *** search
- #include "stdafx.h"
- #include "RandomProps.h"
-
- int random_placement_platform = 140, random_placement_any = 150, random_placement_on = 50,
- random_placement_between = 0, random_placement_under = 20;
-
- static int random_object = 0;
-
- CRandomProps::CRandomProps(CWnd* pParent)
- : CDialog(CRandomProps::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CRandomProps)
- //}}AFX_DATA_INIT
- }
-
- void CRandomProps::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CRandomProps)
- DDX_Control(pDX, IDC_RANDPROPS_UNDER, m_Under);
- DDX_Control(pDX, IDC_RANDPROPS_PLATFORM, m_Platform);
- DDX_Control(pDX, IDC_RANDPROPS_ON, m_On);
- DDX_Control(pDX, IDC_RANDPROPS_BETWEEN, m_Between);
- DDX_Control(pDX, IDC_RANDPROPS_ANY, m_Any);
- DDX_Control(pDX, IDC_RANDOMPROPS_SLIDER, m_Slider);
- DDX_Control(pDX, IDC_RANDOMPROPS_LIST, m_List);
- //}}AFX_DATA_MAP
- }
-
- BEGIN_MESSAGE_MAP(CRandomProps, CDialog)
- //{{AFX_MSG_MAP(CRandomProps)
- ON_LBN_SELCHANGE(IDC_RANDOMPROPS_LIST, OnSelchangeRandompropsList)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- static char *place(tplacement p)
- {
- switch(p)
- {
- case PLACEMENT_ANY:
- return "ANY";
-
- case PLACEMENT_PLATFORM:
- return "PLATFORM";
-
- case PLACEMENT_ON_PLATFORM:
- return "ON PLATFORM";
-
- case PLACEMENT_BETWEEN_PLATFORMS:
- return "BETWEEN PLATFORMS";
-
- case PLACEMENT_UNDER_PLATFORM:
- return "UNDER PLATFORM";
- }
-
- return 0;
- }
-
- BOOL CRandomProps::OnInitDialog()
- {
- CDialog::OnInitDialog();
-
- m_Platform.SetRange(0, 300);
- m_Platform.SetTicFreq(100);
- m_Platform.SetPos(random_placement_platform);
-
- m_Any.SetRange(0, 300);
- m_Any.SetTicFreq(100);
- m_Any.SetPos(random_placement_any);
-
- m_On.SetRange(0, 300);
- m_On.SetTicFreq(100);
- m_On.SetPos(random_placement_on);
-
- m_Between.SetRange(0, 300);
- m_Between.SetTicFreq(100);
- m_Between.SetPos(random_placement_between);
-
- m_Under.SetRange(0, 300);
- m_Under.SetTicFreq(100);
- m_Under.SetPos(random_placement_under);
-
- for (cProperties *p = props; p != 0; p = (cProperties *)p->next)
- if (p->placement != PLACEMENT_NEVER)
- {
- int i = m_List.AddString(construct("%s / %s / %s", place(p->placement), p->type, p->name));
- m_List.SetItemDataPtr(i, p);
- }
-
- m_List.SetCurSel(random_object);
-
- SetSlider();
-
- return TRUE;
- }
-
- void CRandomProps::OnOK()
- {
- random_placement_platform = m_Platform.GetPos();
- random_placement_any = m_Any.GetPos();
- random_placement_on = m_On.GetPos();
- random_placement_between = m_Between.GetPos();
- random_placement_under = m_Under.GetPos();
-
- AcceptSliders();
-
- CDialog::OnOK();
- }
-
- void CRandomProps::OnSelchangeRandompropsList()
- {
- AcceptSliders();
-
- SetSlider();
- }
-
- void CRandomProps::SetSlider()
- {
- // Set slider range
-
- m_Slider.SetRange(0, 1000);
- m_Slider.SetTicFreq(100);
-
- // Get selected object
-
- random_object = m_List.GetCurSel();
-
- // Set slider value
-
- m_Slider.SetPos(((cProperties *)m_List.GetItemDataPtr(random_object))->occurence);
- }
-
- void CRandomProps::AcceptSliders()
- {
- // Save slider value
-
- ((cProperties *)m_List.GetItemDataPtr(random_object))->occurence = m_Slider.GetPos();
- }
-